package centerberg.game;

import java.awt.Font;
import java.awt.Graphics2D;

public class VictoryMenu extends Menu
{
    protected String levelName;
    protected long time;
    
    public VictoryMenu(String levelName, long time)
    {
        super("Victory!");
        
        this.levelName = levelName;
        this.time = time;
        
        Button levels = new Button("Again");
        levels.setAction(new Action() {
            public void execute() {
                MenuSystem.showMenu(new LevelSelectMenu());
            }
        });
        buttons.add(levels);
        
        Button quit = new Button("Quit");
        quit.setAction(new Action() {
            public void execute() {
                System.exit(0);
            }
        });
        buttons.add(quit);
    }
    
    protected int draw(Graphics2D g)
    {
        g.setFont(g.getFont().deriveFont(Font.PLAIN, 18f));
        
        String str = String.format("You beat %s in %d'%01ds", levelName, time / 1000, time % 1000 / 100);
        
        int width = g.getFontMetrics().stringWidth(str);
        int x = (MENU_WIDTH - width) / 2;
        
        g.drawString(str, x, 100);
        
        return 200;
    }
}